<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">

    </div>
</body>
<script src="../react@17.js"></script>
<script src="../react-dom@17.js"></script>
<script src="../babel.js"></script>
<script type="text/babel">
    let userList = ["张三","王五","李四","赵六"];
    let orderList = [
        {
            name:"笔记本",
            price:1999,
            num:1,
            id:111
        },{
            name:"手机",
            price:2999,
            num:1,
            id:2222
        },{
            name:"电视",
            price:999,
            num:2,
            id:3333
        }
    ]
    let ol = (
        <ol>
            {
                /*  map 列表循环不能使用foreach */
                /* 列表循环得到每一项必须要绑定一个唯一标识key */
                /* 
                  diff算法：新老dom树同级比较
                  key的作用：有利于diff算法的比较，提高渲染效率
                */
            }
           {
            userList.map((item,index)=>{
                return <li key={index}>{item}</li>
            })
           }    
        </ol>
    )
    let ul = (
        <ul>
            {
                orderList.map((item,index)=>{
                    return <li key={item.id}>{item.name}-----{item.price}----{item.num}</li>
                })
            }
        </ul>
    )
    let div = (
        <div>
             {ol}
             {ul}
        </div>
    )
    ReactDOM.render(div,document.getElementById("root"))
</script>
</html>